#include<stdio.h>
#include<string.h>

int main()
{
    FILE* fp = fopen("./bite", "wb+");
    if(fp == NULL)
    {
        perror("fopen error");
        return -1;
    }
    fseek(fp , 0, SEEK_SET);
    char *data = "linux so easy!\n";
    size_t ret = fwrite(data, 1, strlen(data), fp);
    if(ret != strlen(data))
    {
        perror("fwrite error");
        return -1;
    }
    fseek(fp, 0, SEEK_SET);
    char buf[1024] = {0};
    ret = fread(buf, 1, 1023, fp);
    if(ret == 0)
    {
        if(ferror(fp))
            printf("fread error\n");
        if(feof(fp))
            printf("read end of file\n");
        return -1;
    }
    printf("%s", buf);
    fclose(fp);
    return 0;
}
